package cn.myframe.dto;

import cn.myframe.util.StockQueue;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 实时交易数据
 * @Author: ynz
 * @Date: 2019/3/20/020 7:55
 * @Version 1.0
 */
@Data
@Accessors(chain = true)
public class RealTimeDto {

    //代码
    private String stockCode;

    //名称
    private String stockName;

    //最新价
    private double stockPrice;

    //涨跌幅
    private double increase;

    //成交量
    private int volume;

    //上一个将交易日的成交量
    private int yVolume;

    //用来分析涨幅的走势
    private int temp = 0;
    private StockQueue<Double> queue_1 = new StockQueue<Double>(60);
    private StockQueue<Double> queue_5 = new StockQueue<Double>(60);
    private StockQueue<Double> queue_10= new StockQueue<Double>(60);
    private StockQueue<Double> queue_30= new StockQueue<Double>(60);
    public RealTimeDto addQueue(Double e){
        queue_1.push(e);
        if(temp%5==0){
            queue_5.push(e);
        }
        if(temp%10==0){
            queue_10.push(e);
        }
        if(temp%30==0){
            queue_30.push(e);
        }
        temp = (temp == 10000 ? 0 : ++temp);
        return this;
    }

    //买卖量委托比
    Integer[] buyArray = new Integer[5];
    Integer[] saleArray = new Integer[5];
    public RealTimeDto addBuy(String ... by){
        int length = Math.min(buyArray.length,by.length);
        for (int i = 0; i < length; i++) {
            buyArray[i] = Integer.parseInt(by[i]);
        }
        return this;
    }

    public RealTimeDto addSale(String ... sale){
        int length = Math.min(saleArray.length,sale.length);
        for (int i = 0; i < length; i++) {
            saleArray[i] = Integer.parseInt(sale[i]);
        }
        return this;
    }








}
